    // @ts-check
    const HtmlWebpackPlugin = require('html-webpack-plugin')
    const {
        CleanWebpackPlugin
    } = require('clean-webpack-plugin')

    module.exports = env => {
        console.log(env)
        let isDev = env === 'development'
    
        const config = {
            entry: './src/main.js',
            mode: isDev?'development':'production' ,
            devtool: isDev?'source-map':'nosources-source-map',
            output: {
                filename: '[name].[contenthash:8].js',
            },
            module: {
                rules: [{
                    test: /\.ts$/,
                    use:'ts-loader'
                }]
            },
            resolve: {
                extensions: ['.js', '.json', '.ts']
            },
            plugins: [
                new HtmlWebpackPlugin({
                    template: './index.html'
                }),
                new CleanWebpackPlugin()
            ]
        }
        return config
    }